import java.util.Iterator;

public class Engine
{
 /**Class that generates the game events + ultimately outcomes
  * @author= JMR 24/5/2010
  */

  private PlayingPlayer [] home_players;
  private PlayingPlayer [] away_players;
  private Pitch pitch;
  private Ball ball;
  private ActionGenerator generator;

  public Engine (Team home_team, Team away_team)
  {
    pitch = new Pitch();

    PlayingTeam h_team = new PlayingTeam (home_team);
    PlayingTeam a_team = new PlayingTeam (away_team);

    home_players = new PlayingPlayer [11];
    away_players = new PlayingPlayer [11];

    generate_playing_players(h_team, home_players);
    generate_playing_players(a_team, away_players);
  }

  private void generate_playing_players (PlayingTeam team, PlayingPlayer [] array)
  {
   /**Generates the playing players from a team and puts them in the array
    */
    PlayingSide side = team.playing_side();
    Iterator <Player> it = side.iterator();
    int count = 0;
    while (it.hasNext()){
      Player player = it.next();
      PlayingPosition position = side.get_position(player);
      PlayingPlayer playing = new PlayingPlayer (player, position, team);
      array[count] = playing;
    }

  }

  public void run ()
  {

  }

}
